/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.Bill;

import entities.BillingDetails;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author Dell
 */
public class TableModelBill implements TableModel{
 private String header[];
 private ArrayList<BillingDetails> billList;

    public String[] getHeader() {
        return header;
    }

    public void setHeader(String[] header) {
        this.header = header;
    }

    public TableModelBill(ArrayList<BillingDetails> billList) {
        this.billList = billList;
    }



    @Override
    public int getRowCount() {
        if (billList != null) {
            return billList.size();
        } else {
            return 0;
        }
       
    }

    @Override
    public int getColumnCount() {
       return header.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return header[columnIndex];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
         if(columnIndex==0){
       return String.class;
       }else if(columnIndex==1){
           return Date.class;
       }
       else {
          return Float.class;
       }
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
       return false;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
      if(columnIndex==0){
          String fullname;
          fullname=billList.get(rowIndex).getPatientDetails().getpFName()+' '+billList.get(rowIndex).getPatientDetails().getpLName();
          return fullname;
      }
 else if(columnIndex==1){
     return billList.get(rowIndex).getbDate();
 }else if(columnIndex==2){
     return billList.get(rowIndex).getbAmount();
 }
      return null;
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void addTableModelListener(TableModelListener l) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
   //     throw new UnsupportedOperationException("Not supported yet.");
    }

}
